package com.pucheng.bracelet.app.database.repository

import androidx.annotation.WorkerThread
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.asFlow
import androidx.lifecycle.asLiveData
import com.pucheng.bracelet.app.App
import com.pucheng.bracelet.app.database.dao.SleepDao
import com.pucheng.bracelet.data.bean.Sao2Bean
import com.pucheng.bracelet.data.bean.SleepBean
import kotlinx.coroutines.flow.Flow

/**
 * 数据库集合
 */
class SleepRepository() {

    //步数
    private val sleepsDao: SleepDao = App.instance.database.sleepDao()

    //查询所有数据
    val allDataTo7DayToSleep = sleepsDao.get7Days()

    //查询所有数据
    val allDataToSleep = sleepsDao.getAll()

    //    //查询指定日期的数据
    fun getSleepsInfoToDate(date: String) = sleepsDao.getDataToDate(date)

    // 插入数据
    @Suppress("RedundantSuspendModifier")
    @WorkerThread
    suspend fun insertSleepToList(list: List<SleepBean>) {
        sleepsDao.insertToList(list)
    }


}